<template>
  <div class="home">
    <el-row class="tac">
      <el-col :span="4">
        <h2>进销存系统</h2>
        <el-menu
            default-active="2"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose">

          <el-submenu index="1" v-show="OneShow">
            <template slot="title">
              <h3>资料管理</h3>
            </template>
            <el-menu-item-group>
              <el-menu-item index="1-1" @click="dateManager(1)">供应商管理</el-menu-item>
              <el-menu-item index="1-2" @click="dateManager(2)">客户管理</el-menu-item>
            </el-menu-item-group>
          </el-submenu>

          <el-submenu index="2" v-show="TwoSHow">
            <template slot="title">
              <h3>采购管理</h3>
            </template>
            <el-menu-item-group>
              <el-menu-item index="2-1" @click="dateManager(8)">采购入库</el-menu-item>
              <el-menu-item index="2-2" @click="dateManager(9)">采购信息查询</el-menu-item>
            </el-menu-item-group>
          </el-submenu>

          <el-submenu index="3" v-show="ThreeShow">
            <template slot="title">
              <h3>销售管理</h3>
            </template>
            <el-menu-item-group>
              <el-menu-item index="3-1" @click="dateManager(10)">销售出库</el-menu-item>
              <el-menu-item index="3-2" @click="dateManager(11)">销售信息查询</el-menu-item>
            </el-menu-item-group>
          </el-submenu>

          <el-submenu index="4" v-show="FourShow">
            <template slot="title">
              <h3>库存管理</h3>
            </template>
            <el-menu-item-group>
              <el-menu-item index="4-1" @click="dateManager(7)">库存一览</el-menu-item>
            </el-menu-item-group>
          </el-submenu>

          <el-submenu index="5" v-show="FiveShow">
            <template slot="title">
              <h3>统计信息</h3>
            </template>
            <el-menu-item-group>
              <el-menu-item index="5-1" @click="dateManager(3)">销售统计</el-menu-item>
              <el-menu-item index="5-2" @click="dateManager(4)">客户统计</el-menu-item>
            </el-menu-item-group>
          </el-submenu>

          <el-submenu index="6" v-show="SixShow">
            <template slot="title">
              <h3>权限管理</h3>
            </template>
            <el-menu-item-group>
              <el-menu-item index="6-1" @click="dateManager(12)">用户管理</el-menu-item>
              <el-menu-item index="6-2" @click="dateManager(13)">角色管理</el-menu-item>
            </el-menu-item-group>
          </el-submenu>

          <el-submenu index="7" v-show="SevenShow">
            <template slot="title">
              <h3>个人信息管理</h3>
            </template>
            <el-menu-item-group>
              <el-menu-item index="7-1" @click="dateManager(6)">修改密码</el-menu-item>
            </el-menu-item-group>
          </el-submenu>

          <el-submenu index="8" v-show="EightShow">
            <template slot="title">
              <h3>日志信息</h3>
            </template>
            <el-menu-item-group>
              <el-menu-item index="7-1" @click="dateManager(5)">日志一览</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-col>

      <el-col :span="18">
        <div class="grid-content bg-purple-light">
          <IndexShow v-show="indexShow"></IndexShow>
        </div>
      </el-col>

      <el-col :span="18">
        <div class="grid-content bg-purple-light">
          <supplier v-show="supplierShow"></supplier>
        </div>
      </el-col>

      <el-col :span="18">
        <div class="grid-content bg-purple-light">
          <Cilent v-show="cilentShow"></Cilent>
        </div>
      </el-col>

      <el-col :span="18">
        <div class="grid-content bg-purple-light">
          <SalesStatistics v-show="sellStatisShow"></SalesStatistics>
        </div>
      </el-col>

      <el-col :span="18">
        <div class="grid-content bg-purple-light">
          <CustomerStatistics v-show="clientStatisShow"></CustomerStatistics>
        </div>
      </el-col>

      <el-col :span="18">
        <div class="grid-content bg-purple-light">
         <UserLoginLog v-show="userLoginLogShow"></UserLoginLog>
        </div>
      </el-col>

      <el-col :span="18">
        <div class="grid-content bg-purple-light">
          <UpdatePwd v-show="updatePwdShow"></UpdatePwd>
        </div>
      </el-col>

      <el-col :span="18">
        <div class="grid-content bg-purple-light">
          <Inventory v-show="inventoryShow"></Inventory>
        </div>
      </el-col>

      <el-col :span="18">
        <div class="grid-content bg-purple-light">
          <ProcurementAndStorage v-show="procurementAndStorageShow"></ProcurementAndStorage>
        </div>
      </el-col>

      <el-col :span="18">
        <div class="grid-content bg-purple-light">
         <Purchasinginformationinquiry v-show="purchasinginformationinquiryShow"></Purchasinginformationinquiry>
        </div>
      </el-col>

      <el-col :span="18">
        <div class="grid-content bg-purple-light">
          <SalesOfOutbound v-show="salesOfOutboundShow"></SalesOfOutbound>
        </div>
      </el-col>

      <el-col :span="18">
        <div class="grid-content bg-purple-light">
          <SalesInformationQuery v-show="salesInformationQueryShow"></SalesInformationQuery>
        </div>
      </el-col>

      <el-col :span="18">
        <div class="grid-content bg-purple-light">
          <SuperSUPro v-show="SuperSUProShow"></SuperSUPro>
        </div>
      </el-col>

      <el-col :span="18">
        <div class="grid-content bg-purple-light">
         <RoleManagement v-show="roleManagementShow"></RoleManagement>
        </div>
      </el-col>

    </el-row>
  </div>
</template>

<script>
import Supplier from "../components/supplier/supplier";
import IndexShow from "../components/indexShow";
import Cilent from "../components/cilent/cilent";
import SalesStatistics from "../components/statistics/salesStatistics";
import CustomerStatistics from "../components/statistics/customerStatistics";
import UserLoginLog from "../components/userLoginLog/userLoginLog";
import UpdatePwd from "../components/pim/updatePwd";
import Inventory from "../components/inventory/inventory";
import ProcurementAndStorage from "../components/purchasingManagement/procurementAndStorage/procurementAndStorage";
import Purchasinginformationinquiry
  from "../components/purchasingManagement/purchasinginformationinquiry/purchasinginformationinquiry";
import SalesOfOutbound from "../components/ salesManagement/salesOfOutbound/salesOfOutbound";
import SalesInformationQuery from "../components/ salesManagement/salesInformationQuery/salesInformationQuery";
import SuperSUPro from "../components/SuperSUPro/SuperSUPro";
import RoleManagement from "../components/roleManagement/roleManagement";

export default {
  name: "index",
  components: {
    RoleManagement,
    SuperSUPro,
    SalesInformationQuery,
    SalesOfOutbound,
    Purchasinginformationinquiry,
    ProcurementAndStorage,
    Inventory, UpdatePwd, UserLoginLog, CustomerStatistics, SalesStatistics, Cilent, IndexShow, Supplier},
  data() {
    return {
      OneShow:false,
      TwoSHow:false,
      ThreeShow:false,
      FourShow:false,
      FiveShow:false,
      SixShow:false,
      SevenShow:false,
      EightShow:false,
      index:[0,1,2,3,4,5,6,7],
      indexShowTwo:[this.OneShow,this.TwoSHow,this.ThreeShow,this.FourShow,this.FiveShow,this.SixShow,this.SevenShow,this.EightShow],
      supplierShow: true,


      indexShow: false,
      cilentShow:false,
      sellStatisShow:false,
      clientStatisShow:false,
      userLoginLogShow:false,
      updatePwdShow:false,
      inventoryShow:false,
      procurementAndStorageShow:false,
      purchasinginformationinquiryShow:false,
      salesOfOutboundShow:false,
      salesInformationQueryShow:false,
      SuperSUProShow:false,
      roleManagementShow:false
    }
  },
  mounted() {
    let loginUserName=sessionStorage.getItem("loginUserName")
    let loginUserPwd=sessionStorage.getItem("loginUserPwd")
    let params = {
      userName: loginUserName,
      userPwd: loginUserPwd
    }
    this.$axios.get('drp/user/loginUser', {params: params}).then(
        r => {
          if (r.data!=''){
            console.log("权限验证")
            console.log(r.data)
            console.log(r.data.roleBeanList)
            for (let i=0;i<r.data.roleBeanList.length;i++){
              console.log('开始验证权限')
              if (r.data.roleBeanList[i].roleName=='资料管理员'){
                this.OneShow=true
                this.SevenShow=true
              }
              if (r.data.roleBeanList[i].roleName=='采购员'){
                console.log(r.data.roleBeanList[i].roleName)
                this.TwoSHow=true
                this.SevenShow=true
              }
              if (r.data.roleBeanList[i].roleName=='销售'){
                this.ThreeShow=true
                this.SevenShow=true
              }
              if (r.data.roleBeanList[i].roleName=='仓库管理员'){
                this.FourShow=true
                this.SevenShow=true
                this.EightShow=true
              }
              if (r.data.roleBeanList[i].roleName=='会计'){
                this.FiveShow=true
                this.SevenShow=true
              }
              if (r.data.roleBeanList[i].roleName=='用户管理员'){
                this.SevenShow=true
                this.SixShow=true
              }
            }
          }else {
            this.$message.error('用户名或密码错误')
          }
        }
    )
    this.dateManager(0)
  },
  methods: {
    handleOpen() {
      console.log("我被打开了")
    },
    handleClose() {
      console.log("我被关上了")
    },
    dateManager(number) {
      if (number==0){
        this.indexShow = true;
        this.supplierShow = false;
        this.cilentShow=false;
        this.sellStatisShow=false
        this.clientStatisShow=false
        this.userLoginLogShow=false
        this.updatePwdShow=false
        this.inventoryShow=false
        this.procurementAndStorageShow=false
        this.purchasinginformationinquiryShow=false
        this.salesOfOutboundShow=false
        this.salesInformationQueryShow=false
        this.SuperSUProShow=false
        this.roleManagementShow=false
      }
      if (number == 1) {
        this.indexShow = false;
        this.supplierShow = true;
        this.cilentShow=false;
        this.sellStatisShow=false
        this.clientStatisShow=false
        this.userLoginLogShow=false
        this.updatePwdShow=false
        this.inventoryShow=false
        this.procurementAndStorageShow=false
        this.purchasinginformationinquiryShow=false
        this.salesOfOutboundShow=false
        this.salesInformationQueryShow=false
        this.SuperSUProShow=false
        this.roleManagementShow=false
      }
      if (number==2){
        this.indexShow = false;
        this.supplierShow = false;
        this.cilentShow=true
        this.sellStatisShow=false
        this.clientStatisShow=false
        this.userLoginLogShow=false
        this.inventoryShow=false
        this.procurementAndStorageShow=false
        this.purchasinginformationinquiryShow=false
        this.salesInformationQueryShow=false
        this.SuperSUProShow=false
        this.roleManagementShow=false
      }
      if (number==3){
        this.sellStatisShow=true;
        this.indexShow=false
        this.supplierShow=false
        this.cilentShow=false
        this.clientStatisShow=false
        this.userLoginLogShow=false
        this.updatePwdShow=false
        this.inventoryShow=false
        this.procurementAndStorageShow=false
        this.purchasinginformationinquiryShow=false
        this.salesOfOutboundShow=false
        this.salesInformationQueryShow=false
        this.SuperSUProShow=false
        this.roleManagementShow=false
      }
      if (number==4){
        this.sellStatisShow=false;
        this.indexShow=false
        this.supplierShow=false
        this.cilentShow=false
        this.clientStatisShow=true
        this.userLoginLogShow=false
        this.updatePwdShow=false
        this.inventoryShow=false
        this.procurementAndStorageShow=false
        this.purchasinginformationinquiryShow=false
        this.salesOfOutboundShow=false
        this.salesInformationQueryShow=false
        this.SuperSUProShow=false
        this.roleManagementShow=false
      }
      if (number==5){
        this.userLoginLogShow=true
        this.sellStatisShow=false;
        this.indexShow=false
        this.supplierShow=false
        this.cilentShow=false
        this.clientStatisShow=false
        this.updatePwdShow=false
        this.inventoryShow=false
        this.procurementAndStorageShow=false
        this.purchasinginformationinquiryShow=false
        this.salesOfOutboundShow=false
        this.salesInformationQueryShow=false
        this.SuperSUProShow=false
        this.roleManagementShow=false
      }
      if (number==6){
        this.updatePwdShow=true
        this.userLoginLogShow=false
        this.sellStatisShow=false;
        this.indexShow=false
        this.supplierShow=false
        this.cilentShow=false
        this.clientStatisShow=false
        this.inventoryShow=false
        this.procurementAndStorageShow=false
        this.purchasinginformationinquiryShow=false
        this.salesOfOutboundShow=false
        this.salesInformationQueryShow=false
        this.SuperSUProShow=false
        this.roleManagementShow=false
      }
      if (number==7){
        this.inventoryShow=true
        this.updatePwdShow=false
        this.userLoginLogShow=false
        this.sellStatisShow=false;
        this.indexShow=false
        this.supplierShow=false
        this.cilentShow=false
        this.clientStatisShow=false
        this.procurementAndStorageShow=false
        this.purchasinginformationinquiryShow=false
        this.salesOfOutboundShow=false
        this.salesInformationQueryShow=false
        this.SuperSUProShow=false
        this.roleManagementShow=false
      }
      if (number==8){
        this.procurementAndStorageShow=true
        this.inventoryShow=false
        this.updatePwdShow=false
        this.userLoginLogShow=false
        this.sellStatisShow=false;
        this.indexShow=false
        this.supplierShow=false
        this.cilentShow=false
        this.clientStatisShow=false
        this.purchasinginformationinquiryShow=false
        this.salesOfOutboundShow=false
        this.salesInformationQueryShow=false
        this.SuperSUProShow=false
        this.roleManagementShow=false
      }
      if (number==9){
        this.purchasinginformationinquiryShow=true
        this.procurementAndStorageShow=false
        this.inventoryShow=false
        this.updatePwdShow=false
        this.userLoginLogShow=false
        this.sellStatisShow=false;
        this.indexShow=false
        this.supplierShow=false
        this.cilentShow=false
        this.clientStatisShow=false
        this.salesOfOutboundShow=false
        this.salesInformationQueryShow=false
        this.SuperSUProShow=false
        this.roleManagementShow=false
      }
      if (number==10){
        this.salesOfOutboundShow=true
        this.purchasinginformationinquiryShow=false
        this.procurementAndStorageShow=false
        this.inventoryShow=false
        this.updatePwdShow=false
        this.userLoginLogShow=false
        this.sellStatisShow=false;
        this.indexShow=false
        this.supplierShow=false
        this.cilentShow=false
        this.clientStatisShow=false
        this.salesInformationQueryShow=false
        this.SuperSUProShow=false
        this.roleManagementShow=false
      }
      if (number==11){
        this.salesInformationQueryShow=true
        this.salesOfOutboundShow=false
        this.purchasinginformationinquiryShow=false
        this.procurementAndStorageShow=false
        this.inventoryShow=false
        this.updatePwdShow=false
        this.userLoginLogShow=false
        this.sellStatisShow=false;
        this.indexShow=false
        this.supplierShow=false
        this.cilentShow=false
        this.clientStatisShow=false
        this.SuperSUProShow=false
        this.roleManagementShow=false
      }
      if (number==12){
        this.SuperSUProShow=true
        this.salesInformationQueryShow=false
        this.salesOfOutboundShow=false
        this.purchasinginformationinquiryShow=false
        this.procurementAndStorageShow=false
        this.inventoryShow=false
        this.updatePwdShow=false
        this.userLoginLogShow=false
        this.sellStatisShow=false;
        this.indexShow=false
        this.supplierShow=false
        this.cilentShow=false
        this.clientStatisShow=false
        this.roleManagementShow=false
      }
      if (number==13){
        this.roleManagementShow=true
        this.SuperSUProShow=false
        this.salesInformationQueryShow=false
        this.salesOfOutboundShow=false
        this.purchasinginformationinquiryShow=false
        this.procurementAndStorageShow=false
        this.inventoryShow=false
        this.updatePwdShow=false
        this.userLoginLogShow=false
        this.sellStatisShow=false;
        this.indexShow=false
        this.supplierShow=false
        this.cilentShow=false
        this.clientStatisShow=false
      }
    },
  }
}
</script>

<style scoped>

</style>